home *** CD-ROM | disk | FTP | other *** search
-
-
- #include <Menus.h>
- #include <Events.h>
- #include <Fonts.h>
- #include <Windows.h>
- #include <TextEdit.h>
- #include <Dialogs.h>
- #include <SegLoad.h>
- #include <TextUtils.h>
- #include <ToolUtils.h>
- #include <Resources.h>
- #include <Timer.h>
- #include <Devices.h>
-
- #include <fp.h>
- #include <QDOffscreen.h>
- #include <QD3D.h>
- #include "RAVE.h"
- #include <QD3DAcceleration.h>
- #include "utils.h"
-
- #include <stdlib.h>
- #include <string.h>
-
-
-
- #define menuBarID 128
-
- #define appleMenuID 128
- #define fileMenuID 129
- #define editMenuID 130
- #define engineMenuID 131
- #define optionsMenuID 132
- #define antialiasingMenuID 133
- #define textureFilterMenuID 134
-
- #define miQuit (((long)fileMenuID << 16) + 6)
-
- #define CheckMem(p) if(!p) DebugStr("\pOut of memory");
-
- #define MYCALLOC(pointer, count) (pointer) = calloc(sizeof (*(pointer)), count); CheckMem(pointer)
- #define MYMALLOC(pointer, count) (pointer) = malloc(sizeof (*(pointer)) * count); CheckMem(pointer)
- #define MYREALLOC(pointer, count) (pointer) = realloc(pointer, sizeof (*(pointer)) * count); CheckMem(pointer)
- #define MYFREE(pointer) free(pointer); pointer = NULL
-
-
- // types
- typedef struct {
- float x, y, z;
- } MyVector;
-
-
- typedef struct {
- long pointNumber;
- float u;
- float v;
- } MyVert;
-
- typedef struct {
- MyVert corner[3];
- short texture;
- } MyTri;
-
-
- typedef struct {
- MyVector x;
- MyVector y;
- MyVector z;
- MyVector w;
- } MyMatrix;
-
-
- typedef struct {
- long bufferSize;
- long count;
- TQAVTexture * list;
- } VList;
-
- typedef struct {
- long bufferSize;
- long count;
- TQAIndexedTriangle * list;
- } TList;
-
- typedef struct {
- long bufferSize;
- long count;
- TQAIndexedTriangle * list;
- } TList2;
-
-
- typedef struct {
- float d; // the distance to the near clipping plane
- float f; // the distance to the far clipping plane
- float h; // half of the view width at distance d from camera
-
- unsigned int doubleBuffer : 1;
- unsigned int noZBuffer : 1;
- unsigned int perspectiveZ : 1;
- unsigned int active : 1;
- unsigned int useMemoryDevice : 1;
- unsigned int useTriMeshes : 1;
- unsigned int saveTransTris : 1; // save transpearant(sp?) trtangles
- unsigned int needsSync : 1;
-
- short textureFilter;
- short antialiasing;
-
- char * errorMessage;
-
- MyVector lightVector;
- float ambient;
-
- TQAEngine *engine;
- short engineNumber;
-
- TQADrawContext *drawContext;
-
- WindowPtr window;
- Rect viewRect;
- float viewHeight;
- float viewWidth;
-
- GWorldPtr backBuffer;
- RgnHandle visRegion;
-
- TList * tList;
- TList * currentTList;
- VList vList; // an allocated buffer of textureCount VList structs
-
- long triangleCount;
-
- long shieldRectCookie;
-
- } MyState;
-
-
- void UpdateMyMenus(WindowPtr w);
- void MyTestSetup(void);
- void SetupNewWindow(void);
- void UnloadTextures(void);
- void DrawFrame(MyState *state);
- void HandleOtherMenu(short menuID, short menuItem);
- void WindowChanged(WindowPtr theWindow);
- void ClosingWindow(WindowPtr theWindow);
-
-
-
- float MyDotProduct(MyVector * v1, MyVector * v2);
- // v3 = v1 - v2
- void MyVectorSubtract(MyVector * v1, MyVector * v2, MyVector * v3);
- void MyVectorAdd(MyVector * v1, MyVector * v2, MyVector * v3);
- // v2 = f * v1
- void MyVectorMultiply(float f, MyVector * v1, MyVector * v2);
- // v3 = v1 - v2
- // taken from 3D Computer Graphics by Alan Watt, p19
- void MyCalculateReflection(MyVector * l, MyVector * n, MyVector * r);
- void MyVectorCrossProduct(MyVector * v1, MyVector * v2, MyVector * v3);
-
- #define HYPOT3(a, b, c) sqrt((a) * (a) + (b) * (b) + (c) * (c))
- float MyVectorLength(MyVector * v1);
- float MyVectorNormalize(MyVector * v1, MyVector * v2);
- float MyVectorDistance(const MyVector * v1, const MyVector * v2);
-
-
-
- void mtest(void);
- void MyMatrixClear(MyMatrix * m1);
- void MyMatrixCat(MyMatrix * m1, MyMatrix * m2, MyMatrix * m3);
- void MyMatrixRotateByMatrix(MyMatrix * m1, MyMatrix * m2);
- void MyMatrixTransformVector(MyMatrix * m1, MyVector * v1, MyVector * v2);
- void MyMatrixRotateVector(MyMatrix * m1, MyVector * v1, MyVector * v2);
- void MyMatrixSetRotateX(float theta, MyMatrix * m1);
- void MyMatrixSetRotateY(float theta, MyMatrix * m1);
- void MyMatrixSetRotateZ(float theta, MyMatrix * m1);
- void MyMatrixNegate(MyMatrix * m1, MyMatrix * m2);
- void MyMatrixScaleLocal(MyMatrix * m1, float scaleFactor, MyMatrix * m2);
-
-
-
- typedef struct {
- long pointCount;
- MyVector * pointList;
- long triangleCount;
- MyTri * triangleList;
- float maxDimention;
-
- short normalMode; // 0 for pervertex or 1 for flat shading
- long * normalTable; // the number of entries is triangleCount for flat shading or triangleCount * 3 for per vertex shading
- long normalCount;
- MyVector * normalList;
- } MyShape;
-
-
- typedef struct {
- MyShape * shape;
- MyMatrix pos; // the position of the object
- unsigned int backfaceCulling : 1;
- float alpha;
- } MyObject;
-
-
-
-
- MyShape * MyShapeNew(void);
- void MyShapeDispose(MyShape * shape);
- MyShape * MyShapeLoad(char * fileName);
- void MyShapeSave(MyShape * shape, char * fileName);
- void MyShapeCalculateNormals(MyShape * shape, short mode);
-
- void WriteGlobe(void);
- void WriteCylinder(void);
-
- typedef struct {
- float roll;
- float pitch;
- float yaw;
- MyMatrix camera;
- unsigned char unusedKey;
- unsigned int stopObjects : 1;
- } GlobalState;
-
-
- extern GlobalState globalState;
-
-
- #define charUp 0x1E
- #define charDown 0x1F
- #define charLeft 0x1C
- #define charRight 0x1D
- #define charPageUp 0x0B
- #define charPageDown 0x0C
- #define charSpace 0x20
- #define charESC 0x1B
- #define charReturn 0x0D
-
-
-
-